package com.facemox.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.facemox.bean.FaceInfo;
import com.facemox.controller.FaceExecuteController;
import com.facemox.mapper.FaceInfoMapper;
import com.facemox.service.FaceInfoService;

@Service
public class FaceInfoServiceImpl implements FaceInfoService {

    @Autowired
    private FaceInfoMapper faceInfoMapper;
    
    @Override
    public int addInterface(FaceInfo faceInfo) {
        int effectLine = faceInfoMapper.insertInterface(faceInfo);
        return effectLine;
    }

    @Override
    public List<FaceInfo> getFaceListByModuleId(Integer moduleId) {
        List<FaceInfo> faceList = faceInfoMapper.getFaceListByModuleId(moduleId);
        String temp="";
        for (FaceInfo faceInfo : faceList) {
            int length = faceInfo.getFaceBody().length();
            if(30<faceInfo.getFaceBody().length()) {
                temp = faceInfo.getFaceBody().substring(0, 30);
            }else {
                temp = faceInfo.getFaceBody().substring(0, faceInfo.getFaceBody().length());
            }
            faceInfo.setFaceBody(temp);
        }
        return faceList;
    }

    @Override
    public FaceInfo findFace(Integer faceId) {
        FaceInfo face = faceInfoMapper.findFace(faceId);
        return face;
    }

    @Override
    public int updateFace(FaceInfo faceInfo) {
       int effectLine = faceInfoMapper.updateFace(faceInfo);
        return effectLine;
    }

    @Override
    public int deleteFaceByFaceId(Integer faceId) {
        int effectLine = faceInfoMapper.deleteFaceByFaceId(faceId);
        return effectLine;
    }

    @Override
    public List<FaceInfo> getFaceListByModuleIdPage(Integer moduleId, Integer fromPage, Integer toPage) {
        List<FaceInfo> faceList = faceInfoMapper.getFaceListByModuleIdPage(moduleId,fromPage,toPage);
        return faceList;
    }

    @Override
    public int getFaceListByModuleIdCount(Integer moduleId) {
        int count = faceInfoMapper.getFaceListByModuleIdCount(moduleId);
        return count;
    }

    @Override
    public List<FaceInfo> getFaceAll() {
        List<FaceInfo> faceList = faceInfoMapper.getFaceAll();
        return faceList;
    }

}
